package com.smart.mobile.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import com.smart.model.mobile.AddressInfo;
import com.smart.util.DBUtil;

public class AddressEditDAO {
	AddressInfo address;
	public AddressEditDAO(AddressInfo address){
		this.address = address;
	}
	public boolean AddressEdit(){
		String sql = "UPDATE address SET name = ?,phonenumber = ?,building = ?,housenumber = ? WHERE Id = ? and userid = ?;";
		
		Connection conn=DBUtil.getConnection();
		try {
			PreparedStatement pSt = conn.prepareCall(sql);
			pSt.setString(1, address.getName());
			pSt.setString(2,address.getPhonenumber());
			pSt.setString(3,address.getBuilding());
			pSt.setString(4, address.getHousenumber());
			pSt.setInt(5, address.getId());
			pSt.setInt(6, address.getUserid());
			if(pSt.executeUpdate()<=0)
				return false;
			else 
				return true;
		} catch (SQLException e) {
			// TODO 自动生成的 catch 块
			e.printStackTrace();
			return false;
		}
	}
}
